﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void VeDiMay(object sender, EventArgs e)
    {
        try
        {
            //Mot bang Table gom nhieu dong TableRow (thuoc tinh Rows cua table) 
            //va mot row gom nhieu o TableCell(thuoc tinh Cells cua TableRow) 
            int iSoDong = Convert.ToInt16(txtSoDong.Text);
            int iSoCot = Convert.ToInt16(txtSoCot.Text);
            for (int i = 1; i <= iSoDong; i++)
            {
                TableRow tb_row = new TableRow();//tao dong
                for (int j = 1; j <= iSoCot; j++)
                {
                    TableCell tb_cell = new TableCell();//tao o
                    tb_cell.Height = Unit.Pixel(30);
                    tb_cell.Width = Unit.Pixel(100);
                    tb_cell.BorderStyle = BorderStyle.Dotted;
                    tb_cell.BorderColor = Color.Purple;
                    tb_row.Cells.Add(tb_cell);//Them o vao dong
                }
                if (i == 1)
                {
                    tb_row.BackColor = Color.Pink;
                }
                Table1.Rows.Add(tb_row);//Them dong vao bang
            }
        }
        catch (Exception ex)
        {
            Response.Write("Nhap Sai Roi May, loi:" + ex.Message);
        }
    }
}